package com.ququ.syb.balance.dao.impl;

import com.ququ.syb.balance.dao.AccountChannelBalanceDao;
import com.ququ.syb.common.pojo.AccountChannelBalance;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

/**
 * Created by Macro on 2016/11/29.
 */
@Scope("prototype")
@Repository
public class AccountChannelBalanceDaoImpl extends BaseDaoImpl<AccountChannelBalance> implements AccountChannelBalanceDao {
    @Override
    public AccountChannelBalance getAccountChannelBalance(String accountid, String channelid) {
        AccountChannelBalance accountChannelBalance = new AccountChannelBalance();
        accountChannelBalance.setAccountid(accountid);
        accountChannelBalance.setChannelid(channelid);
        return super.getEntity(accountChannelBalance);
    }

    @Override
    public Integer addBalance(String accountid, String channelid, long amount)
    {
        Integer ret;
        AccountChannelBalance accountChannelBalance = new AccountChannelBalance();
        accountChannelBalance.setAccountid(accountid);
        accountChannelBalance.setChannelid(channelid);
        accountChannelBalance.setBalance(amount);   //变动余额
        accountChannelBalance.setLastmodifytime(new Date());
        ret = super.update(accountChannelBalance);
        return ret;
    }

    @Override
    public List<AccountChannelBalance> getAccountChannelBalances(String accountid) {
        AccountChannelBalance accountChannelBalance = new AccountChannelBalance();
        accountChannelBalance.setAccountid(accountid);
        return super.getList(accountChannelBalance);
    }
}
